<?php

namespace App\Extensions\Renderable;

use App\Extensions\LayerRowAction;
use App\TransverseBill;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Grid;
use Encore\Admin\Grid\Displayers\Actions;
use Illuminate\Contracts\Support\Renderable;

class TransverseBillRenderable implements Renderable
{
    public function render($key = '')
    {
        $user = Admin::user();
        $grid = new Grid(new TransverseBill());
        $grid->model()->where('transverse_id', $key)->orderByDesc('id');
        $grid->column('amount', __('到账金额'));
        $grid->column('pay_date', __('到账时间'));
        //$grid->column('creator.name', __('操作人'));
        $grid->column('created_at', __('Created at'));
        //$grid->resource(admin_route('transverseBills.index'));
        $grid->actions(function (Actions $actions) {
            $actions->disableView();
            $actions->disableDelete();
            $actions->disableEdit();
            $actions->append(new LayerRowAction(admin_route('transverseBills.change', [$actions->row->id]), '编辑',500,500));
        });
        if ($user->role_type != 1) {
            $grid->disableActions();
        }
        $grid->disableBatchActions();
        $grid->disablePagination();
        $grid->setView('admin.grid.modal.table');
        return $grid->render();
    }


}
